package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-04-05
 * Time: 10:19
 */
public class UDPDictServer extends UDPEchoServer{

    Map<String, String> map = new HashMap<>();


    public UDPDictServer(int port) throws SocketException {
        super(port);
        map.put("cat", "猫");
        map.put("dog", "狗");
        map.put("pig", "猪");
        map.put("confident", "自信的");
    }

    @Override
    public String process(String request) {
        String ret = map.get(request);
        return ret == null ? "不认识这个单词" : ret;
    }

    public static void main(String[] args) throws IOException {
        UDPDictServer udpDictServer = new UDPDictServer(9090);
        udpDictServer.start();
    }
}
